import React, { Component } from 'react';

// 定义一个React组件 
class TodoList extends React.Component {

    constructor(props){
        super(props);
        this.state = {
            list :[
                'aaa',
                'bbb'
            ]
        }

    }

	handleBtnClick(){
		//alert('Hello');
        //this.state.list.push("hello");
        this.setState(
            {
                list:[...this.state.list,'hello']
            }
        )
	}

  render() {
    // jsx 语法
    return (
      <div className="TodoList">
        <div>
        	<input/>
        	<button onClick={this.handleBtnClick.bind(this)}>add</button>
        </div>

        <ul>
            {
                this.state.list.map(
                    (item) => {
                        return <li>{item}</li>
                    }
                )
            }
        </ul>
        
      </div>
    );
  }
}

export default TodoList;
